<%-- 
    Document   : login
    Created on : May 6, 2012, 10:14:54 AM
    Author     : ghaban
--%>

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> 
<%@taglib uri="http://java.sun.com/jsp/jstl/xml" prefix="x" %>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page trimDirectiveWhitespaces="true" %>

<LINK href="stylesheet.css" rel="stylesheet" type="text/css">
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>WebBucks Online Coffee Company!</title>
        <style>.error { color: red; } .success { color: green; }</style>
    </head>
    <body>
        <div id="content">
            <div id="loginpane">
                <c:choose>
                    <c:when test="${! empty validUser && validUser == true}">
                        ${currentUser}
                        <a href="/webbucks-war/IndexServlet?action=logout">Log out</a>
                    </c:when>
                    <c:otherwise>
                        <a href="login.jsp">Login or register</a>
                    </c:otherwise>
                </c:choose> 
                <a href="/webbucks-war/Manager">Manage shop</a>
            </div>
            
            <a href="/webbucks-war/IndexServlet?action=toIndex">Till startsidan</a>
            <div id="header">
                <h1>WebBucks!</h1>
            </div>
            
            
            
            
            
            <div id="login_wrapper">
                <div id="registerform">
                    
                    
                    <h2>Sign up for a new account </h2>
                    <c:if test="${ ! empty validInput && validInput == false}">
                        <div class="error">${(validInput)?null:(incorrectInput)}</div>
                    </c:if>
                    <form action="/webbucks-war/IndexServlet?action=addUser" method=post>
                        <p>
                            Username:                        
                            <input type="text" name="user" value="${param.user}"/>                                          
                        </p>
                        <p>
                            Password:
                            <input type="password" name="password" value = ""/>
                        </p>
                        <p>
                            Verify password:
                            <input type="password" name="password2" value = "" />
                        </p>
                        <p> 
                            Email:                        
                            <input type = "text" name = "email" value = "${param.email}" />                                          
                        </p>
                        <p>
                            First Name:                        
                            <input type = "text" name = "firstName" value = "${param.firstName}" />                         
                        </p>
                        <p>
                            Last Name:                        
                            <input type = "text" name = "lastName" value = "${param.lastName}" />                                          
                        </p>
                        <p>
                            Personal Number:                            
                            <input type = "text" name = "persNumber" value = "${param.persNumber}" />                                          
                        </p>
                        <p>
                            Street Address:                        
                            <input type = "text" name = "street" value = "${param.street}"/>                                          
                        </p>
                        <p>
                            City:                        
                            <input type = "text" name = "city" value = "${param.city}"/>
      
                        </p>
                        <p>
                            Zipcode:
                            <input type = "text" name = "zip" value = "${param.zip}"/>              
                        </p>
                        
                        <input type="submit" value="Register">
                    </form>
                </div> 
                
                <div  id="loginform">
                    
                    <h2>Existing user</h2>
                    <c:if test="${ ! empty validUser &&                 
                                   validUser == false}">
                        <div class="error">${(validUser)?null:(message)}</div>
                    </c:if>
                    
                    <form method="POST" action="/webbucks-war/IndexServlet?action=login" >
                        <p>
                            Username:<input type="text" name="varUser"/>
                        </p>
                        <p>
                            Password:<input type="password" name="pw"/>
                        </p>
                        <input type="submit" value="Log In"/>
                        <input type="reset"/>     
                    </form>
                </div> 
            </div>
        </div>                           
    </body>
</html>
